//
//  SafeCertifyView.m
//  bitcoin
//
//  Created by caiyajun on 2018/5/14.
//  Copyright © 2018年 比特币. All rights reserved.
//

#import "SafeCertifyView.h"
@interface SafeCertifyView()
@property (weak, nonatomic) IBOutlet UIView *contentView;
@property (weak, nonatomic) IBOutlet UIView *phoneView;
@property (weak, nonatomic) IBOutlet UIView *phoneCertifyView;
@property (weak, nonatomic) IBOutlet UIView *emailView;
@property (weak, nonatomic) IBOutlet UIView *emailCertifyView;
@property (weak, nonatomic) IBOutlet UIButton *sureButton;
@property (weak, nonatomic) IBOutlet UIButton *cancelBtn;

@end
@implementation SafeCertifyView
+ (instancetype)xib
{
    return [[NSBundle mainBundle] loadNibNamed:@"SafeCertifyView" owner:self options:nil][0];
}
- (void)awakeFromNib
{
    [super awakeFromNib];
    //增加监听，当键盘出现或改变时收出消息
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
    //增加监听，当键退出时收出消息
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
    view.backgroundColor = [UIColor blackColor];
    view.alpha = 0.75;
    [self addSubview:view];
    self.alpha = 1;
    self.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight);
    [self addSubview:self.contentView];
    
    self.phoneView.layer.borderColor = RGBColor(69, 72, 90).CGColor;
    self.phoneView.layer.borderWidth = 1.0f;
    
    self.phoneCertifyView.layer.borderColor = RGBColor(69, 72, 90).CGColor;
    self.phoneCertifyView.layer.borderWidth = 1.0f;
    
    self.emailView.layer.borderColor = RGBColor(69, 72, 90).CGColor;
    self.emailView.layer.borderWidth = 1.0f;
    
    self.emailCertifyView.layer.borderColor = RGBColor(69, 72, 90).CGColor;
    self.emailCertifyView.layer.borderWidth = 1.0f;
    
    [_phoneTF setValue:[UIColor colorWithHexString:@"#606378"] forKeyPath:@"_placeholderLabel.textColor"];
    [_phoneCertifyTF setValue:[UIColor colorWithHexString:@"#606378"] forKeyPath:@"_placeholderLabel.textColor"];
    [_emailTF setValue:[UIColor colorWithHexString:@"#606378"] forKeyPath:@"_placeholderLabel.textColor"];
    [_emailCertifyTF setValue:[UIColor colorWithHexString:@"#606378"] forKeyPath:@"_placeholderLabel.textColor"];
    
    
    [self.sureButton setBackgroundImage:[UIImage imageWithColor:RGBColor(86, 54, 157)] forState:(UIControlStateHighlighted)];
    [self.cancelBtn setBackgroundImage:[UIImage imageWithColor:RGBColor(178, 121, 20)] forState:(UIControlStateHighlighted)];
}




- (IBAction)sendAction:(LCGrayButton *)sender {
    if (self.sendActionBlock) {
        self.sendActionBlock(sender.tag);
    }
    
    
    
}
- (IBAction)submitAction:(UIButton *)sender {
    if (self.submitActionBlock) {
        self.submitActionBlock(sender.tag);
    }
    
}

//当键盘出现或改变时调用
- (void)keyboardWillShow:(NSNotification *)aNotification {
    //获取键盘的高度
    NSDictionary *userInfo = [aNotification userInfo];
    NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
    CGRect keyboardRect = [aValue CGRectValue];
    int height = keyboardRect.size.height;
    self.contentView.frame=CGRectMake(0, ScreenHeight-333-height, ScreenWidth, 461);
    
}
- (void)keyboardWillHide:(NSNotification *)aNotification {
    //获取键盘的高度
    NSDictionary *userInfo = [aNotification userInfo];
    NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
    CGRect keyboardRect = [aValue CGRectValue];
    CGFloat height = keyboardRect.size.height;
    
    self.contentView.frame=CGRectMake(0, ScreenHeight-461, ScreenWidth, 461);
    
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [self endEditing:YES];
}

- (void)dealloc{
    //取消监听
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

@end
